473,418 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Dropdown menu adding wrong value to database

Hey guys,

I was recently given the task of fixing a PHP application page. I don't know PHP, but I do have extensive knowledge of java, js and c/c#/c++.

That being said, I'm at a loss to fix my problem. The PHP page is a registration form with names, birthdays, etc, all your standard stuff.

When you fill out the birthday and submit it, the birth day is almost always 1 - sometimes it's 2(very infrequently) and sometimes it will roll back to 31(no provision in code for different lengths of the months).

I've attached the code for the birth day drop down. I attempted to add the debug lines and neither of them worked for me. The birth month and birth year code all works as it should, only problem being with the day.

Any insight offered would be greatly appreciated.

Expand|Select|Wrap|Line Numbers
  1.                 echo "<select size='1' name='child_dob_day[".$child."]'>";
  2.                 for ($day=1;$day<=31;$day++)
  3.                 {
  4.                         echo "<option value='".$day."'";
  5.                         if ($form->values["child_dob_day"][$child] == $day)
  6.                                 echo " selected";
  7.                         echo ">".$day."</option>";
  8.                 }
  9.                 echo "</select>";
May 8 '10 #1
6 1647
chathura86
227 100+
check your html source if the select box is populated properly

Regards
May 8 '10 #2
@chathura86
I'm not sure what you mean...the days are added to the drop down by the for loop, how else would the box be populated?
May 8 '10 #3
Dormilich
8,658 Expert Mod 8TB
out of interest, what kind of object is $form?
May 9 '10 #4
Markus
6,050 Expert 4TB
Look at the source of your page. That is, right-click -> view source. You'll see the rendered HTML. Post it here, and from there we might be able to deduce the problem more efficiently.
May 9 '10 #5
chathura86
227 100+
@Dormilich
it could be a instance of a form object, some (including me) creates form objects
from a class (custom made), especially when dealing with ajax so we can send the form values as a json object and map with the form object, im not sure may be some frameworks also support this facility.

Regards
May 9 '10 #6
Expand|Select|Wrap|Line Numbers
  1. <select size='1' name='child_dob_day[1]'><option value='1'>1</option>
  2. <option value='2'>2</option>
  3. <option value='3'>3</option>
  4. <option value='4'>4</option>
  5. <option value='5'>5</option>
  6. <option value='6'>6</option>
  7. <option value='7'>7</option>
  8. <option value='8'>8</option>
  9. <option value='9'>9</option>
  10. <option value='10'>10</option><option value='11'>11</option><option value='12'>12</option><option value='13'>13</option><option value='14'>14</option><option value='15'>15</option><option value='16'>16</option><option value='17'>17</option><option value='18'>18</option><option value='19'>19</option><option value='20'>20</option><option value='21'>21</option><option value='22'>22</option><option value='23'>23</option><option value='24'>24</option><option value='25'>25</option><option value='26'>26</option><option value='27'>27</option><option value='28'>28</option><option value='29'>29</option><option value='30'>30</option><option value='31'>31</option></select>
all the values match up, anything else you'd like to see?

edit: changed code format so it wasn't one huge line...and just a couple lines ;)
May 10 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Mosher | last post by:
Hi all, I am looking for some event handler auto-calc help on a form that takes user input through text fields and dropdown menus. I would like some of the text fields to be auto populated when...
5
by: Derek | last post by:
Let's say I have a dynamic list/menu, which gets its values from a database table, for example a list of contact people where the value is an ID number and the label is the name. However, if the...
2
by: Calvin KD | last post by:
Hi everyone, Can someone show me or point me in the right direction as how to create a "dropdown menu" which displays the menu items as a separete layer over the top of the contents of the page...
12
deephill
by: deephill | last post by:
hi i need form dependency. Can u check below code? <p>1. Are you married?</p> <p>
1
akhan
by: akhan | last post by:
i used the following code to enter data in dropdown menu : <? $con=mysql_connect("","",""); mysql_select_db('investment',$con); $query="select *from personal_info"; $res =...
3
by: Ninio | last post by:
I have a simple form with a dropdown menu that consists of 3 option and each option should retrieve a query from a database. i have been looking all over the place and can't seem to find how to do...
1
SHOverine
by: SHOverine | last post by:
Recently my web host decided to "upgrade". This change rendered many of my pages useless and I am scrambling to fix the issues, so you may see several posts from me in the coming days. My first...
19
by: Jim | last post by:
Hi, I have two questions/problems pertaining to CSS horizontal dropdown menus and am hoping that someone here can help me out. (1) I'm having a problem centering the menu. I picked up the...
3
by: jerrydigital | last post by:
good evening, I am trying to allow my users to enter in text if they don't find their option on my drop down menu. In the code below, I can get a text box to show up when I select 'Other' on the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.